// 问题管理
var problemColumns = [{
    id: 'delName',
    title: '当前处理人',
    type: 'string',
    width: 100,
    columnClass: 'text-center'
},
    {
        id: 'create_time',
        title: '提交时间',
        type: 'date',
        format:'yyyy-MM-dd',
        otype:'time_stamp_ms',
        width: 100,
        columnClass: 'text-center'
    },
    {
        id: 'from_name',
        title: '来源',
        type: 'string',
        columnClass: 'text-center'
    },
    {
        id: 'createName',
        title: '提交人',
        type: 'string',
        width: 75,
        columnClass: 'text-center'
    },
    {
        id: 'department',
        title: '问题处理部门',
        type: 'string',
        columnClass: 'text-center'
    },
    {
        id: 'prb_level',
        title: '优先级',
        type: 'string',
        width: 80,
        columnClass: 'text-center',
        resolution: function (value) {
            var content = '';
            if (value == 1) {
                content += '低';
            }
            if (value == 2) {
                content += '中';
            }
            if (value == 3) {
                content += '高';
            }
            return content;
        }
    },
    {
        id: 'version',
        title: '基本版本号',
        type: 'string',
        width: 100,
        columnClass: 'text-center'
    },
    {
        id: 'prb_desc',
        title: '问题描述',
        type: 'string',
        columnClass: 'text-left'
    },
    // {
    //     id: 'operation',
    //     title: '操作',
    //     type: 'string',
    //     width: 80,
    //     columnClass: 'text-center',
    //     resolution: function (value, record, column, grid, dataNo, columnNo) {
    //         var content = '';
    //         content += '<button class="btn btn-xs btn-success" onclick="editproblem(' + record.id + ',' + record.problemType + ')"><i class="fa fa-edit"></i>  待办</button>';
    //         return content;
    //     }
    // }
];
function findProblemList($CertusJsonAjax) {
    $CertusJsonAjax.dataInit("findProblemList2",{"proId":proId},problemColumns,'problemContainer','problemToolBarContainer');
}

// 需求管理
var demandColumns = [{
    id: 'delName',
    title: '当前处理人',
    type: 'string',
    width: 100,
    columnClass: 'text-center'
},
    {
        id: 'create_time',
        title: '提交时间',
        type: 'date',
        format:'yyyy-MM-dd',
        otype:'time_stamp_ms',
        width: 100,
        columnClass: 'text-center'
    },
    {
        id: 'from_name',
        title: '来源',
        type: 'string',
        columnClass: 'text-center'
    },
    {
        id: 'createName',
        title: '提交人',
        type: 'string',
        width: 100,
        columnClass: 'text-center'
    },
    {
        id: 'department',
        title: '需求处理部门',
        type: 'string',
        columnClass: 'text-center'
    },
    {
        id: 'dm_level',
        title: '优先级',
        type: 'string',
        width: 80,
        columnClass: 'text-center',
        resolution: function (value) {
            var content = '';
            if (value == 1) {
                content += '低';
            }
            if (value == 2) {
                content += '中';
            }
            if (value == 3) {
                content += '高';
            }
            return content;
        }
    },
    {
        id: 'version',
        title: '基本版本号',
        type: 'string',
        width: 100,
        columnClass: 'text-center'
    },
    {
        id: 'dm_desc',
        title: '需求描述',
        type: 'string',
        columnClass: 'text-left'
    },
    // {
    //     id: 'operation',
    //     title: '操作',
    //     type: 'string',
    //     width: 80,
    //     columnClass: 'text-center',
    //     resolution: function (value, record, column, grid, dataNo, columnNo) {
    //         var content = '';
    //         content += '<button class="btn btn-xs btn-success" onclick="editdemand(' + record.id + ',' + record.demandType + ')"><i class="fa fa-edit"></i>  待办</button>';
    //         return content;
    //     }
    // }
];


function findDemanList($CertusJsonAjax) {
    $CertusJsonAjax.dataInit("findDemanList2",{"proId":proId},demandColumns,'demandContainer','demandToolBarContainer');
}

$(".submit").on('click',function () {
    var arr =$("form").serializeArray();
    var data = {};
    for (var i=0;i<arr.length;i++){
        data[arr[i].name] = arr[i].value;
    };
    data.proId= proId;
    $certusUtils.ajax("addDeman",{"data":JSON.stringify(data)},function(response){
        layer.msg("提交成功");
        toLoadHtml(52);
    });
});

if(proBaseInfo.proState!="1"){
    $("#isAdd").hide();
}
//所属公司
$certusUtils.ajax("companyListByViewCode",{},function (response) {
    var data = JSON.parse(response.data);
    for (var i=0;i<data.length;i++){
        $("#companys").append("<option value='"+data[i].companyId+"'>"+data[i].company+"</option>");
    }
});

function getDept() {
    $certusUtils.ajax("deptList",{companyCode:$("#companys").val()},function (response) {
        var data= JSON.parse(response.data);
        for (var i=0;i<data.length;i++){
            $("#department").append("<option value='"+data[i].departmentId+"'>"+data[i].department+"</option>");
        }
    });
}

function findDept() {
    getDept();
}


function toBack() {
    toLoadHtml(52);
}
function toBackp() {
    toLoadHtml(51);
}
$(".submit1").on('click',function () {
    var arr =$("form").serializeArray();
    var data = {};
    for (var i=0;i<arr.length;i++){
        data[arr[i].name] = arr[i].value;
    };
    data.proId= proId;
    $certusUtils.ajax("toAddProblem",{"data":JSON.stringify(data)},function(response){
        layer.msg("提交成功");
        window.history.back();
    });
})
//文件上传统一字段
function showfile() {
    $(".hidefile").show();
    $("#isUpload").val(1);
}

function hidefile() {
    $(".hidefile").hide();
    $("#isUpload").val(0);
}